package com.ny.demo;

import java.util.List;

public class TestList {
    public void addEmployee(List<Employee> list, Employee employee){

        list.add(employee);
    }
    //查询所以员工信息
    public void findAllEmployee(List<Employee> list){

        for (int i=0;i<list.size();i++) {
            System.out.println(list.get(i));
        }
    }
    //根据编号查询员工信息
    public Employee findEmployeeNumber(List<Employee>list,String number){
        for (int i=0;i< list.size();i++){
            if (number.equals(list.get(i).getNumber())){
                return list.get(i);
            }
        }
        return null;
    }
    //根据员工编号删除某个员工信息
    public void deleteEmployeeNumber(List<Employee>list,String number){
        for (int i=0;i< list.size();i++){
            if (number.equals(list.get(i).getNumber())){
                list. remove(i);
                System.out.println(list);
            }
        }
    }
    //根据员工编号修改某个员工信息，例如10001的年龄修改成20
    public void updateEmployee(List<Employee> list, Employee employee) {
        for (int i = 0; i < list.size(); i++) {
            if (employee.getNumber().equals(list.get(i).getNumber())) {
                list.set(i,list.get(i));

                System.out.println(list);
            }
        }
    }
}
